package com.hudson.plugin.result.collector.server.datastore.internal.entity;

import javax.persistence.*;
import java.util.Collection;

/**
 * User: yuxinlei
 * Date: 4/13/11
 * Time: 1:51 PM
 */
@javax.persistence.Table(name = "views", catalog = "reportdb")
@Entity
public class ViewsEntity {
    private int id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private String icafeProject;

    @javax.persistence.Column(name = "icafe_project", nullable = true, insertable = true, updatable = true, length = 256, precision = 0)
    @Basic
    public String getIcafeProject() {
        return icafeProject;
    }

    public void setIcafeProject(String icafeProject) {
        this.icafeProject = icafeProject;
    }

    private String module;

    @javax.persistence.Column(name = "module", nullable = true, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getModule() {
        return module;
    }

    public void setModule(String module) {
        this.module = module;
    }

    private String version;

    @javax.persistence.Column(name = "version", nullable = true, insertable = true, updatable = true, length = 32, precision = 0)
    @Basic
    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    private String viewName;

    @javax.persistence.Column(name = "view_name", nullable = true, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getViewName() {
        return viewName;
    }

    public void setViewName(String viewName) {
        this.viewName = viewName;
    }

    private String url;

    @javax.persistence.Column(name = "url", nullable = true, insertable = true, updatable = true, length = 256, precision = 0)
    @Basic
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ViewsEntity that = (ViewsEntity) o;

        if (id != that.id) return false;
        if (icafeProject != null ? !icafeProject.equals(that.icafeProject) : that.icafeProject != null) return false;
        if (module != null ? !module.equals(that.module) : that.module != null) return false;
        if (url != null ? !url.equals(that.url) : that.url != null) return false;
        if (version != null ? !version.equals(that.version) : that.version != null) return false;
        if (viewName != null ? !viewName.equals(that.viewName) : that.viewName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (icafeProject != null ? icafeProject.hashCode() : 0);
        result = 31 * result + (module != null ? module.hashCode() : 0);
        result = 31 * result + (version != null ? version.hashCode() : 0);
        result = 31 * result + (viewName != null ? viewName.hashCode() : 0);
        result = 31 * result + (url != null ? url.hashCode() : 0);
        return result;
    }

    private Collection<ProjectsEntity> projectsesById;

    @OneToMany(mappedBy = "viewsByViewId")
    public Collection<ProjectsEntity> getProjectsesById() {
        return projectsesById;
    }

    public void setProjectsesById(Collection<ProjectsEntity> projectsesById) {
        this.projectsesById = projectsesById;
    }

    private HudsonsEntity hudsonsByHudsonId;

    @ManyToOne
    public
    @JoinColumn(name = "hudson_id", referencedColumnName = "id")
    HudsonsEntity getHudsonsByHudsonId() {
        return hudsonsByHudsonId;
    }

    public void setHudsonsByHudsonId(HudsonsEntity hudsonsByHudsonId) {
        this.hudsonsByHudsonId = hudsonsByHudsonId;
    }
}
